const Lname = document.querySelector('#Login-name')
const Lpwd = document.querySelector('#Login-pwd')
const btn_Lgt = document.querySelector('#Login1')
const check = document.querySelector('#Login-check')
btn_Lgt.addEventListener('click',function(e){
    // alert(1)
    e.preventDefault()
    const name=Lname.value
    const pwd=Lpwd.value
    // alert(2)
    
    utils.post('./api/user/login.php',{name,pwd},resp=>{
        // alert(3)
        if(resp.code==200){
            if(check.checked){
                utils.setCookie('name',name,{ expires:7,path:'/'})
            }else{
                utils.setCookie('name',name,{ path:'/'})
            }
        $('#LoginModal').modal('hide')
        location.replace('http://localhost:8080/Bootstrap_shop')
        alert(resp.body.msg)
        }else{
            alert(resp.body.msg)
        }
    })
})


/* btn_Lgt.onclick=function(){
    const name=Lname.value,pwd=Lpwd.value
    utils.post('./api/user/login.php',{name,pwd},resp=>{
        if(resp.code===200){
            if(check.checked){
                utils.setCookie('name',name,{ expires:3,path:'/'})
            }else{
                utils.setCookie('name',name,{ path:'/'})
            }
            $('#LoginModal').modal('hide')
            alert(resp.body.msg)
        }else{
            alert(resp.body.msg)
        }
    })
    return false
} */